//
//  LHTabBarController.m
//  play
//
//  Created by zhouLiHuan on 2016/12/9.
//  Copyright © 2016年 zhouLiHuan. All rights reserved.
//

#import "LHTabBarController.h"
#import "LHNavigationController.h"
#import "BoardViewController.h"
#import "VideoViewController.h"
#import "FamilyViewController.h"

@interface LHTabBarController ()

@end

@implementation LHTabBarController

- (void)dealloc{

}

+ (void)initialize{

    [self setupTabbarTheme];
    [self setupTabBarItmeTheme];
}

//设置tabar的样式
+ (void)setupTabbarTheme{

    UITabBar *tabBar = [UITabBar appearance];
    [tabBar setBarTintColor:[UIColor whiteColor]];
    
}

//设置UITabBarItem的样式
+ (void)setupTabBarItmeTheme{

    UITabBarItem *tabBarItem = [UITabBarItem appearance];
    
    //normal
    NSMutableDictionary *textAttrs = [NSMutableDictionary dictionary];
    textAttrs[NSForegroundColorAttributeName] = TextDarkColor;
    textAttrs[NSFontAttributeName] = [UIFont systemFontOfSize:11*kScaling750];
    [tabBarItem setTitleTextAttributes:textAttrs forState:UIControlStateNormal];
    
    //selected
    NSMutableDictionary *selectTextAttrs = [NSMutableDictionary dictionaryWithCapacity:textAttrs];
    selectTextAttrs[NSForegroundColorAttributeName] = RGBCOLOR_HEX(0xfc5c6c);
    [tabBarItem setTitleTextAttributes:selectTextAttrs forState:UIControlStateSelected];
    
    

}

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    [self addSubChildVc];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}


//添加自控制器
- (void)addSubChildVc{

    [self addOneChild:[VideoViewController new] title:@"视频" imageName:@"Homepage" selectImageName:@"Homepage_seleted"];
     [self addOneChild:[BoardViewController new] title:@"画板" imageName:@"Advertising_seleted" selectImageName:@"Advertising_seleted"];
     [self addOneChild:[FamilyViewController new] title:@"家人" imageName:@"Mine" selectImageName:@"Mine"];
    
    
}

- (void)addOneChild:(UIViewController *)childVc title:(NSString *)title imageName:(NSString *)imageName selectImageName:(NSString *)selectedImageName{

    childVc.title = title;
    childVc.tabBarItem.image = [UIImage imageNamed:imageName];
    UIImage *selctedImg = [UIImage imageNamed:selectedImageName];
    childVc.tabBarItem.selectedImage = selctedImg;
    
    //自定义导航栏控制器
    LHNavigationController *navVc = [[LHNavigationController alloc] initWithRootViewController:childVc];
    [self addChildViewController:navVc];

}

@end
